<?php
require_once("database.php");
class xl_school extends database
{
    function lay_truong($uid) 
	{		
		$sql = "SELECT scname FROM school WHERE scid = '$uid' LIMIT 0,1";
		$this->setQuery($sql);
		return $this->loadResult();
	}
	
	function danh_sach($vi_tri, $so_luong)
	{
		$vi_tri = intval($vi_tri);
		$so_luong = intval($so_luong);
		$sql = "select * from school limit $vi_tri, $so_luong";
		$this->setQuery($sql);
		return $this->loadAllRow();
	}
	function so_luong()
	{
		$sql = "select count(*) from school";
		$this->setQuery($sql);
		return $this->loadResult();
	}
	function xem($scid)
	{
		
		$sql = "select * from school where scid = '$scid'";
		$this->setQuery($sql);
		return $this->loadRow();
	}
	function xoa($scid)
	{
		
		$sql = "delete from school where scid = '$scid'";
		$this->setQuery($sql);
		$this->query();
	}
	function them($scname)
	{
		$scname = addslashes($scname);

		$sql = "INSERT INTO school(scname) VALUES ('$scname')";
		$this->setQuery($sql);
		return $this->query();
	}
	function cap_nhat($scid, $scname)
	{
		$scname = addslashes($scname);

		$sql ="UPDATE school SET scname= '$scname' WHERE scid = '$scid'";
		$this->setQuery($sql);
		return $this->query();
	}
	function tim_kiem ($tu_khoa)
	{
		$sql = "select * from school where	$scname like %tu_khoa%"; 
		$this->setQuery($sql);
		return $this->loadAllRow();	
	}
 }
?>